package com.study.csc.a07threadmethod4;

/**
 * @author csc
 * @Date 2023/10/28 15:12
 * @PackageName:com.study.csc.a07threadmethod4
 * @ClassName: TestYield
 * @Description: TODO
 * @Version 1.0
 */
public class TestYield {


    public static void main(String[] args) {
        MyYield myYield = new MyYield();
        new Thread(myYield,"a").start();
        new Thread(myYield,"b").start();
    }



}


class  MyYield implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程开始执行");
        Thread.yield();//礼让
        System.out.println(Thread.currentThread().getName()+"线程停止执行");
    }
}